package com.erps.model;

import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;

public class ResRequestModel extends Model<ResRequestModel> {
	private static final ResRequestModel request = new ResRequestModel();

	public Page<ResRequestModel> paginate(int pageNumber, int pageSize,String user_id,String req_status) {
		StringBuffer sql = new StringBuffer();
		sql.append(" from ersp_res_request x,");
		sql.append(" ersp_res_info y,ersp_sys_org o");
		sql.append(" where o.id=y.org_id");
		sql.append(" and x.id=y.id");
		sql.append(" and x.user_id=?");
		
		if(req_status.equals("all")){
			
			 
			 return paginate(pageNumber, pageSize, "select x.*,y.*", sql.toString(),user_id);
		}else{
		
			sql.append(" and x.req_status=?");
			
		     return paginate(pageNumber, pageSize, "select *", sql.toString(), user_id, req_status);
		}
	}

}
